import 'package:flutter/material.dart';

/// 动画配置工具类
/// 提供统一的动画参数配置，确保应用内动画的一致性
class AnimationConfig {
  
  /// 动画持续时间配置
  static const Duration fast = Duration(milliseconds: 200);
  static const Duration medium = Duration(milliseconds: 300);
  static const Duration slow = Duration(milliseconds: 500);
  static const Duration shimmer = Duration(milliseconds: 1500);
  
  /// 缓动曲线配置
  static const Curve easeInOut = Curves.easeInOut;
  static const Curve easeOut = Curves.easeOut;
  static const Curve easeIn = Curves.easeIn;
  static const Curve bounceOut = Curves.bounceOut;
  static const Curve elasticOut = Curves.elasticOut;
  
  /// 骨架屏动画配置
  static const Duration skeletonShimmer = Duration(milliseconds: 1500);
  static const Curve skeletonCurve = Curves.easeInOut;
  
  /// 状态转换动画配置
  static const Duration stateTransition = Duration(milliseconds: 250);
  static const Curve stateCurve = Curves.easeOutCubic;
  
  /// 按钮动画配置
  static const Duration buttonPress = Duration(milliseconds: 100);
  static const Duration buttonRelease = Duration(milliseconds: 200);
  static const Curve buttonCurve = Curves.easeInOut;
  
  /// 列表项动画配置
  static const Duration listItemEnter = Duration(milliseconds: 300);
  static const Duration listItemExit = Duration(milliseconds: 200);
  static const Curve listItemCurve = Curves.easeOut;
  
  /// 淡入淡出动画配置
  static const Duration fadeIn = Duration(milliseconds: 300);
  static const Duration fadeOut = Duration(milliseconds: 200);
  static const Curve fadeCurve = Curves.easeInOut;
  
  /// 缩放动画配置
  static const Duration scaleIn = Duration(milliseconds: 200);
  static const Duration scaleOut = Duration(milliseconds: 150);
  static const Curve scaleCurve = Curves.easeOutBack;
  
  /// 滑动动画配置
  static const Duration slideIn = Duration(milliseconds: 300);
  static const Duration slideOut = Duration(milliseconds: 250);
  static const Curve slideCurve = Curves.easeOutQuart;
  
  /// 创建带有标准配置的动画控制器
  static AnimationController createController({
    required TickerProvider vsync,
    Duration? duration,
  }) {
    return AnimationController(
      duration: duration ?? medium,
      vsync: vsync,
    );
  }
  
  /// 创建淡入淡出动画
  static Animation<double> createFadeAnimation(
    AnimationController controller, {
    Duration? duration,
    Curve? curve,
  }) {
    return Tween<double>(
      begin: 0.0,
      end: 1.0,
    ).animate(CurvedAnimation(
      parent: controller,
      curve: curve ?? fadeCurve,
    ));
  }
  
  /// 创建缩放动画
  static Animation<double> createScaleAnimation(
    AnimationController controller, {
    double begin = 0.8,
    double end = 1.0,
    Curve? curve,
  }) {
    return Tween<double>(
      begin: begin,
      end: end,
    ).animate(CurvedAnimation(
      parent: controller,
      curve: curve ?? scaleCurve,
    ));
  }
  
  /// 创建滑动动画
  static Animation<Offset> createSlideAnimation(
    AnimationController controller, {
    Offset begin = const Offset(0.0, 1.0),
    Offset end = Offset.zero,
    Curve? curve,
  }) {
    return Tween<Offset>(
      begin: begin,
      end: end,
    ).animate(CurvedAnimation(
      parent: controller,
      curve: curve ?? slideCurve,
    ));
  }
  
  /// 创建骨架屏闪烁动画
  static Animation<double> createShimmerAnimation(
    AnimationController controller,
  ) {
    return Tween<double>(
      begin: -1.0,
      end: 1.0,
    ).animate(CurvedAnimation(
      parent: controller,
      curve: skeletonCurve,
    ));
  }
}